Hands-On Robotics with JavaScript by Kassandra Perch

Hands-On Robotics with JavaScript by Kassandra Perch

Author:Kassandra Perch
Language: eng
Format: epub
Publisher: Packt Publishing
Published: 2018-08-31T05:40:21+00:00


Putting a piece of paper on the motor shaft

Either roll the sticky end of a long sticky note around the motor shaft, or tape a long strip of paper to it. It should look something like this:

After the relatively simple construction of our toy, let's code some randomness!

Coding the randomness to start/stop the motor

We want the motor to start at a random speed for anywhere from 1-10 seconds, then stop for 1-10 seconds, and repeat. We also want whether it goes forward or backward to be random. I limited the speed to 75—anything faster was too much for my cats!

In your cat-toy.js file, get rid of the board.repl.inject statement and add the following:

startMovement()



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.